#include <iostream>
#include <vector>
#include <sstream>

using namespace std;

int main(){
    string A;
    int B;
    cin>>A>>B;
    vector<int> Q;
    int R=0;
    
    int a = A[0]-'0';
    
    for(int i=0;i<A.length();i++){    
        if(a<B){
            if(i == A.length()-1){
                R = a;
                break;
            }   
            int a1 = A[i+1]-'0';
            a = a*10+a1;
            Q.push_back(a/B);
            a = a%B;
        } else {
            if(i == A.length()-1){
                Q.push_back(a/B);
                R = a%B;
                break;
            }
            Q.push_back(a/B);
            a = a%B;
        }
    }
    
    for(int i=0;i<Q.size();i++){
        cout<<Q[i];
    }
    cout<<" "<<R<<endl;
    
    return 0;
}
